package com.whq.beans;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;

import java.awt.*;

@Controller
public class BeanUserController1 {
    static UserService userService1;

    @Autowired
    public void set(UserService userService){
        System.out.println("加载了");
        userService1 = userService;
    }

    public int getUser1(){
        return userService1.get();
    }

    public static void main(String[] args) {
        System.out.println(userService1);
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("spring-config.xml");
        BeanUserController1 beanUserController1 = beanFactory.getBean("beanUserController1",BeanUserController1.class);
        System.out.println(beanUserController1.getUser1());

    }

}
